<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var i,
        //   计算1+11+111+1111
        sum = 0;
      tmp = 0;
      for (i = 1; i <= 9; i++) {
        tmp += "1";
        //tmp字符串加法运算 可以直接变成11 111 1111
        sum += parseInt(tmp);
        //sum=sum+parseInt(tmp)
      }
      document.write(sum);
    </script>
  </body>
</html>
